
// 实现旋转效果 -> 通过切换类名

(function (document) {
  const oSwiperItems = document.querySelectorAll('.swiper-item'),
        classNames = []; // 保存swiper上的类名

  let t = null;

  const init = () => {
    collectClassNames();
    swiperAction();
  }

  function render() {
    let oSwiperItem = null;

    for (let i = 0; i < oSwiperItems.length; i ++) {
      oSwiperItem = oSwiperItems[i];
      oSwiperItem.className = classNames[i];
    }
  }

  function collectClassNames() { // 收集swiperItem上的类名
    let oSwiperItem = null;

    for (let i = 0; i < oSwiperItems.length; i ++) {
      oSwiperItem = oSwiperItems[i];
      classNames.push(oSwiperItem.className);
    }
  }

  function setClassNames() {
    classNames.unshift(classNames.pop()); // 切换类名
    // console.log(classNames);
    render(); // 设置类名
  }

  function swiperAction() {
    t = setInterval(setClassNames, 2500);
  }

  init();
})(document);
